// component/j-scroll/j-scroll.js
var app = getApp()
Component({
	properties: {
		keyCatid: {
			type: Number,
			value: 0,
			observer: function (newVal, oldVal) {
				var that = this;
				wx.request({
					url: app.globalData.host + 'index.php/api/goods/goodsInfo?admin_id=' + app.globalData.admin_id + '&type=' + newVal + '&code=3',
					success: function (e) {
						// console.log(e)
						that.setData({
							items: e.data.result.slice(0, that.data.limit)
						})
						if (that.data.items.length <= 0) {
							that.setData({
								no: true
							})
						} else {
							that.setData({
								no: false
							})
						}
					}
				})
			}
		},
		// 显示多少数据量
		limit: {
			type: Number,
			value: 999,
		},
		// 每行多少个
		rowNum: {
			type: Number,
			value: 2,
			observer: function (newVal, oldVal) {
				console.log(newVal)
				var w = (100 / newVal).toFixed(2)
				this.setData({
					width: w,
				})
			}
		},
		height: {
			type: Number,
			value: 260,
		},
		// 显示文字（名字，简介，价格）
		limitDes: {
			type: Number,
			value: 3,
		},
		// 显示文字对齐方式
		align: {
			type: String,
			value: 'left',
		},
	},


	data: {
		items: [],
		width: 50,
		no: false
	},

	methods: {
		onClick: function (e) {
			// console.log(e)
			this.triggerEvent('clickevent', e.currentTarget.dataset)
		}
	}
})
